package com.example.compose_componet

import android.annotation.SuppressLint
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.lifecycle.viewmodel.compose.viewModel
import com.example.compose_componet.components.BottomBar
import com.example.compose_componet.components.Topbar
import com.example.compose_componet.ui.theme.Compose_componetTheme
import com.example.compose_componet.viewModel.WeViewModel

class MainActivity : ComponentActivity() {
    @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
    @OptIn(ExperimentalMaterial3Api::class)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            val viewModel: WeViewModel = viewModel()
            Compose_componetTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    Scaffold(
                        topBar = {
                            Column() {
                                when(viewModel.selectIndex){
                                    0-> Topbar("学习")
                                    1-> Topbar("任务")
                                    2->  Topbar("我的")
                                }
                                when(viewModel.selectIndex){
                                    0-> Text(text = "我是学习")
                                    1-> Text(text = "我是任务")
                                    2-> Text(text = "我是我的")
                                }
                            }


                            // 设置AppBar
                            // 这里可以使用TopAppBar组件设置顶部栏

                        },
                        bottomBar = {
                            // 设置BottomAppBar
                            // 这里可以使用BottomAppBar组件设置底部栏
                            BottomBar()
                        },
                        floatingActionButton = {
                            // 设置FloatingActionButton
                            // 这里可以使用FloatingActionButton组件设置浮动操作按钮
                        },
                        content = {
                            // 设置屏幕内容

                        }
                    )
                }
            }
        }
    }
}



